package cho07;

/**
 * Created by 春旺 on 2017/4/2.
 */

import java.util.Scanner;
    public class Average752
    {
        public static void main (String[] args)
        {
            Scanner s = new Scanner(System.in);
            Scanner n = new Scanner(System.in);
            String again ="y";


            while(again.equalsIgnoreCase("y"))
            {

                System.out.println("How many number do you want to enter???(Less than 50)");
                int size = s.nextInt();
                int position =0;
                double doublenum [] = new double[size];
                System.out.println("Enter "+ size + " numbers");
                for(int times=1;times <= size ; times++)
                {
                    double enter = s.nextDouble();
                    doublenum[position] = enter;
                    position++;
                }


                System.out.println();


                System.out.println("MEAN");
                double total =0;
                position =0;
                while(position<size)
                {
                    total=total+ doublenum[position];
                    position++;
                }
                System.out.println(total / size);
                System.out.println();
                System.out.println("sd");
                double mean = total/size;
                while(position<size)
                {
                    total = total+(doublenum[position]-mean);
                    position++;
                }
                double sd = Math.sqrt((Math.pow(total,2))/(size -1));
                System.out.println(sd);

                System.out.println("Do you want to try again?(y/n)");
                again=n.nextLine();
            }
        }
    }


